﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NetworkManagement;

namespace LorraineSec.MessageLib.Messages
{
    public sealed class AssetListRequest : EncryptedMessage
    {
        #region Format Constants
        /*
         * Format:
         *         4
         * | CompartmentID | 
         */

        private const int ENC_COMPID_LENGTH = 4;

        private const int ENC_COMPID_OFFSET = 0;

        private const int ENC_KNOWN_LENGTH = ENC_COMPID_LENGTH;
        #endregion

        public uint CompartmentID;

        public AssetListRequest()
        {
            init();
        }

        public AssetListRequest(byte[] bytes)
            : base(bytes)
        {
            init();
            decode();
        }

        private void init()
        {
            MessageID = (ushort)LorraineSecMessageFactory.MessageID.ASSET_LIST_REQUEST;
        }

        public override void decrypt(CryptoManager crypt)
        {
            base.decrypt(crypt);
            CompartmentID = Bytes.getUInt32(encData, ENC_COMPID_OFFSET);
        }

        public override void encrypt(CryptoManager crypt)
        {
            encData = new byte[ENC_KNOWN_LENGTH];
            Bytes.setValue(encData, ENC_COMPID_OFFSET, CompartmentID);
            base.encrypt(crypt);
        }
    }
}
